home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: seebs@solon.com (Peter Seebach)
- Newsgroups: comp.std.c,comp.lang.c.moderated
- Subject: Re: printf() format extensions - looking for beta testers...
- Date: 13 Apr 1996 09:40:26 -0500
- Organization: Usenet Fact Police (Undercover)
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4koecq$8up@solutions.solon.com>
- References: <4kgljv$l2p@solutions.solon.com> <4klicn$ndl@solutions.solon.com> <4kll9l$o5h@solutions.solon.com> <4kobun$8i2@solutions.solon.com>
- Reply-To: seebs@solon.com
- NNTP-Posting-Host: solutions.solon.com
-
- In article <4kobun$8i2@solutions.solon.com>,
- Sean 'Captain Napalm' Conner <spc@gate.net> wrote:
- > But there is a potential problem with doing this. What if you use a
- >pre-compiled module that has extended printf(), say, using '%#' (unbeknownst
- >to you, the documentation may be a bit lax (happens enough)). What happens
- >when you try to extend printf() using '%#'? With possible different
- >semantics (different type, say)?
-
- That's why mine is not like the plan 9 fmtinstall(). In my current design,
- assuming that we have
- typedef int (*fmtconv)();
- (args will vary as I struggle with the design), you install a format with
- fmtconv format(int c, fmtconv);
-
- which installs a new format and returns the previous one. There are special
- magic fmtconvs called FMT_IGN (to make a character no longer a format
- character), FMT_DFL (to reset to the default), and FMT_GET, which doesn't
- install anything, but returns the current conversion func.
-
- This has been described as overengineering, but is there for precisely
- that reason.
-
- %# would be a poor choice; the conversion func for %# is one which returns
- a magic cookie to set the alternate format flag. :)
-
- But yeah, I've been thinking about it.
-
- > -spc (Or does your printf() report a redefinition error?)
-
- Nope.
-
- I'm also considering the sfio magic of
- %(foo)
- calling a conversion func attached to the string "foo". This seems
- frivolous for small apps, but if you look at a POSIX system, with
- N+1 magic types like uid_t and gid_t, it might be useful.
-
- I've been starting to get dazzled by the vast array of cool ideas
- various previous implementations have come up with. sfio has a base
- flag, which could make the lives of thousands of first year students much
- easier.
-
- The problem is mostly coming up with a consistent way of parsing
- things such that no currently standardized call to printf will change
- behavior unless you've done something else (like call format()) which
- is not standardized.
-
- (Well, that would be trivial; but doing that and providing useful extensions
- is more difficult.)
-
- -s
- --
- Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach.
- C/Unix wizard -- C/Unix questions? Send mail for help. No, really!
- FUCK the communications decency act. Goddamned government. [literally.]
- The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
-